package com.demo.jpa.dao;

import com.demo.jpa.pojo.Pet;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PetRepository extends JpaRepository<Pet, Integer> {
    Pet findPetByName(String name);
    List<Pet> findAllByNameAndAgeBetween(String name, int age1, int age2);
    List<Pet> findAllByNameLikeAndAgeBetween(String name,int ageMin,int ageMax);
    @Query("from Pet where name like '%:name%'")
    List<Pet> search(String name);
}
